<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/templates/template.xhtml">
	<ui:define name="pageTitle">Construtora</ui:define>
	<ui:define name="pageHeader">Listagem de Construtoras</ui:define>
	<ui:define name="body">
		<h:panelGrid columns="1" style="width:100%">

		</h:panelGrid>
		<h:form id="lista">
			<p:dataTable id="dtConstrutora" value="#{construtoraBean.lista}"
				var="construtora" editable="true" paginator="true" rows="5"
				style="font-size:12px;margin-top:10px"
				emptyMessage="Nenhum cadastro efetuado! "
				rendered="#{not empty construtoraBean.lista}">
				<f:facet name="header">
					<h:outputText value="LISTAGEM DE CONSTRUTORAS" />
				</f:facet>
				<p:column headerText="CÓD." style="width:5%;font-size:12px;">
					<div align="center">#{construtora.id}</div>
				</p:column>

				<p:column headerText="RAZÃO SOCIAL" width="40%"
					style="font-size:12px;">
					#{construtora.razaoSocial}
				</p:column>

				<p:column headerText="CNPJ" width="15%" style="font-size:12px;">
				#{construtora.cnpj}
				</p:column>

				<p:column headerText="TELEFONE" width="15%" style="font-size:12px;">
				#{construtora.telefone}
				</p:column>
				<p:column style="width:2%">
					<h:commandLink action="#{construtoraBean.excluir(false)}"
						onclick="if(!confirm('Deseja realmente excluir a construtora #{construtora.razaoSocial}?')) return false;">
						<div align="center">
							<h:graphicImage url="/templates/Imagens/delete-2.png" />
						</div>
						<f:setPropertyActionListener
							target="#{construtoraBean.construtoraSelecionada}"
							value="#{construtora}" />
					</h:commandLink>
					<h:outputText value=" " />
				</p:column>
				<p:column style="width:2%">
					<h:commandLink action="#{construtoraBean.Exibir}">
						<h:graphicImage url="/templates/Imagens/icon_pencil.png" />
						<f:setPropertyActionListener
							target="#{construtoraBean.construtoraSelecionada}"
							value="#{construtora}" />

					</h:commandLink>
				</p:column>

			</p:dataTable>
		</h:form>

		<!--  
			<p:dialog id="modalDialog" header="Gerenciamento de Construtoras"
			widgetVar="dialogGerConstrutora" modal="true" height="600"
			width="900" appendToBody="true" resizable="false" draggable="false">
		-->
		<p />
		<p />

		<h:form id="edicao">
			<div align="center">
				<h:inputHidden value="#{construtoraBean.construtoraSelecionada.id}" />
				<div align="right" style="margin-right: 4%">
					<p:panel style="width:15%">
						<p:commandLink action="#{construtoraBean.novo()}" update=":edicao">
							<h:graphicImage url="/templates/Imagens/Add.png"
								style="margin-right:20px" />
						</p:commandLink>

						<p:commandLink action="#{construtoraBean.salvar()}"
							update=":lista,:edicao">
							<h:graphicImage url="/templates/Imagens/Salvar.png"
								style="margin-right:10px" />
						</p:commandLink>
					</p:panel>
				</div>
				<p:fieldset legend="Gerenciamento de Construtora:"
					toggleable="false" style="width:90%;font-size:12px;">

					<p:messages globalOnly="true" />

					<div id="caixa1">
						<h:graphicImage id="foto" url="/templates/Imagens/add-user.png"
							style="width:110px;height:110px;" />
						<p />
						<p:fileUpload rendered="true"
							fileUploadListener="#{fileUploadController.upload}" auto="true"
							label="Carregar" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
							sizeLimit="100000" description="Selecione uma imagem!" />

					</div>
					<div id="caixa2">
						<h:panelGrid style="float: left;width:100%;font-size:12px;">
							<p:row>
								<p:column>
									<h:outputLabel id="lblCnpj" value="Cnpj:" for="cnpj"
										style="width:30%;float: left;font-weight: bold;margin-right:20px" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<p:inputMask id="CNPJ" mask="999.999.999/9999-99"
										value="#{construtoraBean.construtoraSelecionada.cnpj}"
										required="true" requiredMessage=" *" />
									<h:message for="CNPJ" errorClass="errorMessage"
										style="font-weight: bold;font-size:18px;color:red" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel id="lblRSocial" value="Razão Social:"
										for="rSocial" style="float: left;font-weight: bold;" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:inputText id="txtNome" style="width:95%"
										converter="toUpperCaseConverter"
										value="#{construtoraBean.construtoraSelecionada.razaoSocial}"
										required="true" requiredMessage=" *">
										<f:ajax event="blur" render="@this" />
									</h:inputText>
									<h:message for="txtNome" errorClass="errorMessage"
										style="font-weight: bold;font-size:18px;color:red" />
								</p:column>
							</p:row>

						</h:panelGrid>
					</div>
				</p:fieldset>
				<p />
				<p:fieldset legend="Contato:" toggleable="false"
					style="width:90%;font-size:12px;">
					<h:panelGrid id="pnContato" style="float: left;width:100%">
						<p:row>
							<p:column>
								<h:outputLabel id="lblCep" value="Cep:" for="cep"
									style="float: left;font-weight: bold;font-size:12px;" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:inputMask id="txtCep" mask="99.999-999"
									value="#{construtoraBean.construtoraSelecionada.cep}"
									required="true" requiredMessage=" *" />
								<h:message for="txtCep" errorClass="errorMessage"
									style="font-weight: bold;font-size:18px;color:red" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputLabel id="lblEndereco" value="Endereço:" for="endereco"
									style="float: left;width:75%;font-weight: bold;font-size:12px;" />
							</p:column>
							<p:column>
								<h:outputLabel id="lblNumero" value="Número:" for="numero"
									style="float: left;width:20%; font-weight: bold;font-size:12px;" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:inputText id="txtEndereco" converter="toUpperCaseConverter"
									style="width:70%;"
									value="#{construtoraBean.construtoraSelecionada.endereco}"
									required="true" requiredMessage=" *">
									<f:ajax event="blur" render="@this" />
								</h:inputText>
								<h:message for="txtEndereco" errorClass="errorMessage"
									style="font-weight: bold;font-size:18px;color:red" />
							</p:column>
							<p:column>
								<p:inputText id="txtNumero" style="width:20%;margin-left:40px"
									value="#{construtoraBean.construtoraSelecionada.numero}"
									required="true" requiredMessage=" *" />
								<h:message for="txtNumero" errorClass="errorMessage"
									style="font-weight: bold;font-size:18px;color:red" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputLabel id="lblComplemento" value="Complemento:"
									for="complemento"
									style="float: left;width:65%; font-weight: bold;font-size:12px;" />
							</p:column>

						</p:row>
						<p:row>
							<p:column>
								<h:inputText id="txtComplemento"
									converter="toUpperCaseConverter" style="width:70%;"
									value="#{construtoraBean.construtoraSelecionada.complemento}"
									required="false">
									<f:ajax event="blur" render="@this" />
								</h:inputText>
							</p:column>


						</p:row>

						<p:row>
							<p:column>
								<h:outputLabel id="lblEstado" value="Estado:" for="Estado"
									style="float: left;width:180px; font-weight: bold;font-size:12px;" />
							</p:column>
							<p:column>
								<h:outputLabel id="lblCidade" value="Cidade:" for="Cidade"
									style="float: left;width:210px; font-weight: bold;font-size:12px;" />
							</p:column>
							<p:column>
								<h:outputLabel id="lblTelefone" value="Telefone:" for="telefone"
									style="float: left;width:20%; font-weight: bold;font-size:12px;" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:selectOneMenu value="#{construtoraBean.estadoSelecionado}"
									style="float: left;width:150px; font-weight: bold;font-size:12px;">
									<f:selectItems value="#{construtoraBean.estadosSelect}"
										itemValue="#{construtoraBean.estadoSelecionado.id}" />
								</p:selectOneMenu>
							</p:column>
							<p:column>
								<p:selectOneMenu value="#{construtoraBean.cidadeSelecionada}"
									style="float: left;width:150px;margin-left:20px; font-weight: bold;font-size:12px;">
									<f:selectItems value="#{construtoraBean.cidadesSelect}"
										itemValue="#{construtoraBean.cidadeSelecionada.id}" />
								</p:selectOneMenu>
							</p:column>
							<p:column>

								<p:inputMask id="txtTelefone" mask="(99)9999.9999"
									style="width:20%;margin-left:40px"
									value="#{construtoraBean.construtoraSelecionada.telefone}" />
							</p:column>

						</p:row>
						<p:row>
							<p:column>
								<h:outputLabel id="lblEmail" value="Email:" for="Email"
									style="float: left;font-weight: bold;font-size:12px;" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:inputText id="txtEmail" style="width:95%"
									converter="toUpperCaseConverter"
									value="#{construtoraBean.construtoraSelecionada.email}"
									required="true" requiredMessage=" *">
									<f:ajax event="blur" render="@this" />
								</h:inputText>
								<h:message for="txtEmail" errorClass="errorMessage"
									style="font-weight: bold;font-size:18px;color:red" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputLabel id="lblSite" value="Site:" for="Site"
									style="float: left;font-weight: bold;font-size:12px;" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:inputText id="txtSite" style="width:95%" required="false"
									converter="toUpperCaseConverter"
									value="#{construtoraBean.construtoraSelecionada.site}">
									<f:ajax event="blur" render="@this" />
								</h:inputText>
							</p:column>
						</p:row>
					</h:panelGrid>
				</p:fieldset>
				<p />

				<p />

			</div>
		</h:form>
		<!--  
		</p:dialog>
		-->
		<p:dialog id="dlgImagem" appendTo="@(body)" width="30%" height="100%"
			header="Gerênciador de Imagens" widgetVar="janDialog" modal="true"
			showEffect="fade" hideEffect="fade">


			<h:panelGrid columns="2" id="pnImagemEdit"
				style="float: center;width:100%">
				<p:row>
					<p:column>
						<div align="center">
							<h:graphicImage url="/templates/Imagens/add-user.png"
								style="width:110px;height:110px;" />
						</div>
					</p:column>
				</p:row>
			</h:panelGrid>

		</p:dialog>

	</ui:define>
</ui:composition>

</html>